package com.aggregate.pay.weixin;

import com.aggregate.pay.weixin.bean.MicropayData;
import com.aggregate.pay.weixin.bean.MicropayResult;
import com.aggregate.pay.weixin.bean.OrderQueryData;
import com.aggregate.pay.weixin.bean.OrderQueryResult;
import com.aggregate.pay.weixin.bean.RefundData;
import com.aggregate.pay.weixin.bean.RefundNotifyData;
import com.aggregate.pay.weixin.bean.RefundQueryData;
import com.aggregate.pay.weixin.bean.RefundQueryResult;
import com.aggregate.pay.weixin.bean.RefundResult;
import com.aggregate.pay.weixin.bean.ReverseData;
import com.aggregate.pay.weixin.bean.ReverseResult;
import com.aggregate.pay.weixin.bean.UnifiedOrderData;
import com.aggregate.pay.weixin.bean.UnifiedOrderResult;
import com.aggregate.pay.weixin.support.Client;
import com.aggregate.pay.weixin.support.Config;
import com.aggregate.pay.weixin.support.Factory;
import com.aggregate.pay.weixin.support.HttpClient;
import com.aggregate.pay.weixin.support.Merch;
import com.aggregate.pay.weixin.support.client.Micropay;
import com.aggregate.pay.weixin.support.client.OrderQuery;
import com.aggregate.pay.weixin.support.client.Refund;
import com.aggregate.pay.weixin.support.client.RefundNotify;
import com.aggregate.pay.weixin.support.client.RefundQuery;
import com.aggregate.pay.weixin.support.client.Reverse;
import com.aggregate.pay.weixin.support.client.UnifiedOrder;

/**
 * 微信官方支付接口工具类，相关配置和接口调用从此类开始
 * @author Moyq5
 * @date 2018年6月15日
 */
public abstract class WeixinApiFactory {

	public static void config(Config config, HttpClient httpClient) {
		Factory.setConfig(config);
		Factory.setHttpClient(httpClient);
	}
	
	@SuppressWarnings("unchecked")
	public static Client<MicropayData, MicropayResult> micropay(Merch info) {
		return (Client<MicropayData, MicropayResult>)Factory.getClient(Micropay.class, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<UnifiedOrderData, UnifiedOrderResult> unifiedOrder(Merch info) {
		return (Client<UnifiedOrderData, UnifiedOrderResult>)Factory.getClient(UnifiedOrder.class, info);
	}
	
	@SuppressWarnings("unchecked")
	public static Client<OrderQueryData, OrderQueryResult> orderQuery(Merch info) {
		return (Client<OrderQueryData, OrderQueryResult>)Factory.getClient(OrderQuery.class, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<ReverseData, ReverseResult> reverse(Merch info) {
		return (Client<ReverseData, ReverseResult>)Factory.getClient(Reverse.class, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<RefundData, RefundResult> refund(Merch info) {
		return (Client<RefundData, RefundResult>)Factory.getClient(Refund.class, info);
	}
	
	@SuppressWarnings("unchecked")
	public static Client<RefundQueryData, RefundQueryResult> refundQuery(Merch info) {
		return (Client<RefundQueryData, RefundQueryResult>)Factory.getClient(RefundQuery.class, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<String, RefundNotifyData> refundNotify(Merch info) {
		return (Client<String, RefundNotifyData>)Factory.getClient(RefundNotify.class, info);
	}

}
